home *** CD-ROM | disk | FTP | other *** search
/ Windows Game Programming for Dummies (2nd Edition) / WinGamProgFD.iso / pc / DirectX SDK / DXSDK / samples / Multimedia / VBSamples / DirectPlay / DXVBMessenger / Client / frmLogin.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2001-10-08  |  6.8 KB  |  191 lines

  1. VERSION 5.00
  2. Begin VB.Form frmLogin 
  3.    BorderStyle     =   4  'Fixed ToolWindow
  4.    Caption         =   "Login"
  5.    ClientHeight    =   3255
  6.    ClientLeft      =   45
  7.    ClientTop       =   285
  8.    ClientWidth     =   4680
  9.    Icon            =   "frmLogin.frx":0000
  10.    LinkTopic       =   "Form1"
  11.    MaxButton       =   0   'False
  12.    MinButton       =   0   'False
  13.    ScaleHeight     =   3255
  14.    ScaleWidth      =   4680
  15.    ShowInTaskbar   =   0   'False
  16.    StartUpPosition =   1  'CenterOwner
  17.    Begin VB.CommandButton cmdCancel 
  18.       Cancel          =   -1  'True
  19.       Caption         =   "Cancel"
  20.       Height          =   375
  21.       Left            =   2520
  22.       TabIndex        =   5
  23.       Top             =   2760
  24.       Width           =   1035
  25.    End
  26.    Begin VB.CommandButton cmdCreate 
  27.       Caption         =   "&Create Account"
  28.       Height          =   375
  29.       Left            =   60
  30.       TabIndex        =   4
  31.       Top             =   2760
  32.       Width           =   1335
  33.    End
  34.    Begin VB.CommandButton cmdLogin 
  35.       Caption         =   "Log on"
  36.       Default         =   -1  'True
  37.       Height          =   375
  38.       Left            =   3600
  39.       TabIndex        =   6
  40.       Top             =   2760
  41.       Width           =   1035
  42.    End
  43.    Begin VB.TextBox txtServerName 
  44.       Height          =   285
  45.       Left            =   60
  46.       TabIndex        =   3
  47.       Top             =   2400
  48.       Width           =   4515
  49.    End
  50.    Begin VB.CheckBox chkRemember 
  51.       Caption         =   "Remember this password"
  52.       Height          =   255
  53.       Left            =   60
  54.       TabIndex        =   2
  55.       Top             =   1860
  56.       Width           =   4515
  57.    End
  58.    Begin VB.TextBox txtPassword 
  59.       Height          =   285
  60.       IMEMode         =   3  'DISABLE
  61.       Left            =   60
  62.       PasswordChar    =   "*"
  63.       TabIndex        =   1
  64.       Top             =   1500
  65.       Width           =   4515
  66.    End
  67.    Begin VB.TextBox txtUserName 
  68.       Height          =   285
  69.       Left            =   60
  70.       TabIndex        =   0
  71.       Top             =   900
  72.       Width           =   4515
  73.    End
  74.    Begin VB.Label Label1 
  75.       BackStyle       =   0  'Transparent
  76.       Caption         =   "Server Name:"
  77.       Height          =   195
  78.       Index           =   3
  79.       Left            =   60
  80.       TabIndex        =   10
  81.       Top             =   2160
  82.       Width           =   1395
  83.    End
  84.    Begin VB.Label Label1 
  85.       BackStyle       =   0  'Transparent
  86.       Caption         =   "Password:"
  87.       Height          =   195
  88.       Index           =   2
  89.       Left            =   60
  90.       TabIndex        =   9
  91.       Top             =   1260
  92.       Width           =   915
  93.    End
  94.    Begin VB.Label Label1 
  95.       BackStyle       =   0  'Transparent
  96.       Caption         =   "UserName:"
  97.       Height          =   195
  98.       Index           =   1
  99.       Left            =   60
  100.       TabIndex        =   8
  101.       Top             =   660
  102.       Width           =   915
  103.    End
  104.    Begin VB.Label Label1 
  105.       BackStyle       =   0  'Transparent
  106.       Caption         =   "Please type in your username, password and server to connect to, or click the 'Create Account' button..."
  107.       Height          =   495
  108.       Index           =   0
  109.       Left            =   60
  110.       TabIndex        =   7
  111.       Top             =   120
  112.       Width           =   4575
  113.    End
  114. Attribute VB_Name = "frmLogin"
  115. Attribute VB_GlobalNameSpace = False
  116. Attribute VB_Creatable = False
  117. Attribute VB_PredeclaredId = True
  118. Attribute VB_Exposed = False
  119. Option Explicit
  120. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  121. '  Copyright (C) 1999-2001 Microsoft Corporation.  All Rights Reserved.
  122. '  File:       frmLogin.frm
  123. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  124. Private Sub cmdCancel_Click()
  125.     Unload Me
  126. End Sub
  127. Private Sub cmdCreate_Click()
  128.     Unload Me
  129.     frmCreate.Show , frmClient
  130. End Sub
  131. Private Sub cmdLogin_Click()
  132.     Dim AppDesc As DPN_APPLICATION_DESC
  133.     gfCreatePlayer = False
  134.     If txtServerName.Text = vbNullString Then 'They didn't enter a server name
  135.         MsgBox "You must enter a server name.", vbOKOnly Or vbInformation, "No server name."
  136.         Exit Sub
  137.     End If
  138.     If txtPassword.Text = vbNullString Then 'They didn't enter a password
  139.         MsgBox "You must enter a password.", vbOKOnly Or vbInformation, "No password."
  140.         Exit Sub
  141.     End If
  142.     If txtUserName.Text = vbNullString Then 'They didn't enter a user name
  143.         MsgBox "You must enter a user name.", vbOKOnly Or vbInformation, "No user name."
  144.         Exit Sub
  145.     End If
  146.     cmdLogin.Enabled = False
  147.     'Now let's save the settings
  148.     SaveSetting gsAppName, "Startup", "ServerName", txtServerName.Text
  149.     SaveSetting gsAppName, "Startup", "Username", txtUserName.Text
  150.     If chkRemember.Value = vbChecked Then
  151.         SaveSetting gsAppName, "Startup", "Password", txtPassword.Text
  152.     Else
  153.         SaveSetting gsAppName, "Startup", "Password", vbNullString
  154.     End If
  155.     If gsServerName = vbNullString Then gsServerName = txtServerName.Text
  156.     If gfConnected And (gsServerName = txtServerName.Text) Then
  157.         'Save the username/password
  158.         gsPass = EncodePassword(txtPassword.Text, glClientSideEncryptionKey)
  159.         gsUserName = txtUserName.Text
  160.         LogonPlayer
  161.     Else
  162.         If gfConnected Then
  163.             InitDPlay 'Re-Initialize DPlay
  164.         End If
  165.         dpas.AddComponentString DPN_KEY_HOSTNAME, txtServerName.Text 'We only want to connect on this host
  166.         'First set up our application description
  167.         With AppDesc
  168.             .guidApplication = AppGuid
  169.         End With
  170.         'Save the username/password
  171.         gsPass = EncodePassword(txtPassword.Text, glClientSideEncryptionKey)
  172.         gsUserName = txtUserName.Text
  173.         On Error Resume Next
  174.         'Try to connect to this server
  175.         dpc.Connect AppDesc, dpas, dpa, 0, ByVal 0&, 0
  176.         If Err.Number <> 0 Then
  177.             MsgBox "This server could not be contacted.  Please check the server name and try again.", vbOKOnly Or vbInformation, "Not found."
  178.             cmdLogin.Enabled = True
  179.             Exit Sub
  180.         End If
  181.     End If
  182. End Sub
  183. Private Sub Form_Load()
  184.     'First retrieve the settings
  185.     txtServerName.Text = GetSetting(gsAppName, "Startup", "ServerName", vbNullString)
  186.     txtUserName.Text = GetSetting(gsAppName, "Startup", "Username", vbNullString)
  187.     txtPassword.Text = GetSetting(gsAppName, "Startup", "Password", vbNullString)
  188.     If txtPassword.Text <> vbNullString Then chkRemember.Value = vbChecked 'We remembered our password
  189.     cmdLogin.Enabled = True
  190. End Sub
  191.